package com.ichir.projects.uiflow.events;

import java.util.HashMap;
import java.util.Map;

/**
 * UI framework Event class.
 * 
 * @author mahieddine
 * @since 1.0.0
 */
public class UiEvent {

	/**
	 * Event ID.
	 */
	private String eventId;
	
	/**
	 * Event attributes.
	 */
	private Map<String, Object> attributes;
	
	/**
	 * Base constructor.
	 * @param eventId event ID
	 */
	public UiEvent(String eventId) {
		this.eventId = eventId;
		attributes = new HashMap<String, Object>();
	}

	/**
	 * Single attribute constructor.
	 * @param eventId event ID
	 * @param key attribute key
	 * @param value attribute value
	 */
	public UiEvent(String eventId, String key, Object value) {
		this(eventId);
		this.attributes.put(key, value);
	}

	/**
	 * Input attributes constructor.
	 * @param eventId event ID
	 * @param attributes event attributes
	 */
	public UiEvent(String eventId, Map<String, Object> attributes) {
		this(eventId);
		this.attributes.putAll(attributes);
	}
	
	/**
	 * Add key-value pair to event attributes
	 * @param key
	 * @param value
	 */
	public void put(String key, Object value) {
		attributes.put(key, value);
	}
	
	/**
	 * Add a set of pair key-value pair attributes.
	 * @param attributes attributes to add
	 */
	public void putAll(Map<String, Object> attributes) {
		attributes.putAll(attributes);
	}
	
	/**
	 * Clear all event attributes.
	 */
	public void clear() {
		attributes.clear();
	}
	
	/**
	 * @return all event attributes
	 */
	public Map<String, Object> getAttributes() {
		return attributes;
	}

	/**
	 * @return event ID
	 */
	public String getEventId() {
		return eventId;
	}

	/**
	 * Set the event ID
	 * @param eventId event ID to set
	 */
	public void setEventId(String eventId) {
		this.eventId = eventId;
	}
}
